package com.yeyi.ytest.java8;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;



public class OptionalTest {
    private final String title;
    private final String author;
    private final List<String> tags;

    public OptionalTest(String title, String author, List<String> tags) {
        this.title = title;
        this.author = author;
        this.tags = tags;
    }

    public String getTitle() {
        return title;
    }

    public String getAuthor() {
        return author;
    }

    public List<String> getTags() {
        return tags;
    }

    @Override
    public String toString() {
        return "Article [title=" + title + ", author=" + author + ", tags=" + tags + "]";
    }
    
    public static void main(String[] args) {
    	OptionalTest tt = new OptionalTest("","",new ArrayList<>());
    	
    	// 连续多个判断直接用多个 map 连接即可
    	Optional.ofNullable(tt).map(u->u.getTags()).map(li->li.get(0)).orElse("sssss");
	}
    
}
